package com.haoshuang.zhouzhoubang.ui.adapter


import android.graphics.Color
import androidx.recyclerview.widget.GridLayoutManager
import com.chad.library.adapter4.BaseQuickAdapter
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemEw2Binding
import com.haoshuang.zhouzhoubang.ui.activity.LookBigImgActivity
import com.lnkj.jialubao.ui.page.bean.EwBean2
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.view.gone
import com.mufeng.libs.utils.view.visible

/**
 * 订单模块中的订单列表适配器
 * */
class EcAdapter(data: MutableList<EwBean2>) :
    BaseBindingQuickAdapter<EwBean2, ItemEw2Binding>(data){


    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: EwBean2?) {
        if (item==null){
            return
        }
        val binding = ItemEw2Binding.bind(holder.itemView)
        binding.apply {
            costName.text=item.cost_name
            costRemark.text=item.cost_remark
            if (item.cost_remark.isNullOrBlank()){
                costRemark.gone()
            }else{
                costRemark.visible()
            }
            if (item.cost_img.size==0&&item.cost_remark.isNullOrBlank()){
                vLine.gone()
            }else{
                vLine.visible()
            }
            if (item.cost_img.size>0){
                rvList.visible()
                var adapter=Image2Adapter(item.cost_img)
                rvList.layoutManager=GridLayoutManager(context,4)
                rvList.adapter=adapter
                adapter.setOnItemClickListener { adapter, view, position ->
                    context.startPage<LookBigImgActivity>("imgBeen" to item.cost_img,"position" to position)
                }

            }else{
                rvList.gone()
            }
            money.text=item.money
            if (item.pay_status=="0"){
                payStatus.setBackgroundResource(R.drawable.bg_2lan)
                payStatus.text="未支付"
            }else{
                payStatus.text="已支付"
                payStatus.setBackgroundResource(R.drawable.bg_2red)
            }


        }
    }

}